import numpy as np
import matplotlib.pyplot as plt

def logistic_function(x, r):
    return r * x * (1 - x)

def plot_logistic_scatter(r, x0, iterations):
    values = []
    x = x0
    for _ in range(iterations):
        values.append(x)
        x = logistic_function(x, r)
    
    plt.scatter(range(iterations), values, s=5)
    plt.xlabel('Iteration')
    plt.ylabel('State Value')
    plt.title(f'Logistic Scatter Plot (r={r}, x0={x0})')
    plt.show()

# 设置参数
r = 3.9  # 控制增长率的参数
x0 = 0.2  # 初始状态值
iterations = 10000  # 迭代次数

# 绘制散点图
plot_logistic_scatter(r, x0, iterations)
